import numpy as np
np.set_printoptions(precision=3, suppress=True)
import pylab
import matplotlib.pyplot as plt
%matplotlib inline
import MotionClouds as mc
fx, fy, ft = mc.get_grids(mc.N_X, mc.N_Y, mc.N_frame)
def show_mc(name):
import os
from IPython.display import display, Image
if os.path.isfile(name + mc.ext):
display(Image(filename=name + mc.ext))
if os.path.isfile(name + '_cube' + mc.ext):
display(Image(filename=name + '_cube' + mc.ext))
from IPython.display import HTML
from base64 import b64encode
video = open(name + mc.vext, "rb").read()
video_encoded = b64encode(video)
video_tag = '<video controls autoplay="autoplay" loop="loop" width=50% src="data:video/x-m4v;base64,{0}">'.format(video_encoded)
display(HTML(data=video_tag))
name = 'color'
z = mc.envelope_color(fx, fy, ft)
if mc.anim_exist(mc.figpath + name): mc.figures(z, mc.figpath + name)
show_mc(mc.figpath + name)
# explore parameters
for alpha in [0.0, 0.5, 1.0, 1.5, 2.0]:
# resp. white(0), pink(1), red(2) or brownian noise (see http://en.wikipedia.org/wiki/1/f_noise
name_ = mc.figpath + name + '-alpha-' + str(alpha).replace('.', '_')
if mc.anim_exist(name_):
z = mc.envelope_color(fx, fy, ft, alpha)
mc.figures(z, name_)
show_mc(name_)
for ft_0 in [0.125, 0.25, 0.5, 1., 2., 4.]:# time space scaling
name_ = mc.figpath + name + '-ft_0-' + str(ft_0).replace('.', '_')
if mc.anim_exist(name_):
z = mc.envelope_color(fx, fy, ft, ft_0=ft_0)
mc.figures(z, name_)
show_mc(name_)
for contrast in [0.1, 0.25, 0.5, 0.75, 1.0, 2.0]:
name_ = mc.figpath + name + '-contrast-' + str(contrast).replace('.', '_')
if mc.anim_exist(name_):
im = mc.rectif(mc.random_cloud(mc.envelope_color(fx, fy, ft)), contrast)
mc.anim_save(im, name_, display=False)
show_mc(name_)
for contrast in [0.1, 0.25, 0.5, 0.75, 1.0, 2.0]:
name_ = mc.figpath + name + '-energy_contrast-' + str(contrast).replace('.', '_')
if mc.anim_exist(name_):
im = mc.rectif(mc.random_cloud(mc.envelope_color(fx, fy, ft)), contrast, method='energy')
mc.anim_save(im, name_, display=False)
show_mc(name_)
for seed in [123456 + step for step in range(7)]:
name_ = mc.figpath + name + '-seed-' + str(seed)
if mc.anim_exist(name_):
mc.anim_save(mc.rectif(mc.random_cloud(mc.envelope_color(fx, fy, ft), seed=seed)), name_, display=False)
show_mc(name_)